package com.cosmoplat.xikai.business.domain.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @ClassName ProductQuality
 * @Description 产品合格率
 * @Author wdf
 * @Date 2025/1/13
 */
@Data
public class ProductQuality {


    @ApiModelProperty(value = "产品编码", example = "产品A")
    private String productCode;

    @ApiModelProperty(value = "产品类型", example = "产品A")
    private String productType;

    /**
     * 生产数量
     */
    @ApiModelProperty(value = "生产数量", example = "100")
    private Integer totalCount;

    /**
     * 合格数量
     */
    @ApiModelProperty(value = "合格数量", example = "90")
    private Integer qualifiedCount;

    /**
     * 不合格数量
     */
    @ApiModelProperty(value = "不合格数量", example = "10")
    private Integer unqualifiedCount;


    /**
     * 合格率
     */
    @ApiModelProperty(value = "合格率", example = "90%")
    private String qualifiedRate;

    /**
     * 计算合格率
     * @date 9:55 2025/1/13
     * @return java.lang.String
     **/
    public String getQualifiedRate() {
        if (totalCount == 0) {
            return "0%";
        } else {
            double qualifiedRate = (double) qualifiedCount / totalCount * 100;
            return String.format("%.2f", qualifiedRate) + "%";
        }

    }
}
